package com.dsx.test.service;

import com.dsx.test.model.LoginUserReq;
import com.dsx.test.properties.JwtProperties;
import com.dsx.test.util.JwtUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @author : tianwenqing
 * @version : 1.0
 * @date : 2020-11-16 19:35
 * @description :
 **/
@Service
@Slf4j
public class LoginService {

    public String login(LoginUserReq loginUserReq) {

        Map<String, String> claims = new HashMap<String, String>() {
            {
                put(JwtProperties.USER_ID, loginUserReq.getPhone());
            }
        };
        String jwtSecret = "123456";
        String token = JwtUtil.getToken(claims, jwtSecret, JwtProperties.EXPIRATION);

        return token;
    }
}
